package com.gjintel.business.professerinfo.controller;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.gjintel.business.professerinfo.dto.ProfesserInfoDto;
import com.gjintel.business.professerinfo.model.Professer;
import com.gjintel.business.professerinfo.service.IProfesserService;

/**
 * @author lpshen 
 * @date 2016-8-18
 */
@RequestMapping("/business/professerinfo")
@Controller
public class ProfesserController {
	@Autowired
	private IProfesserService professerService;
	
	/**
	 * @description 专家信息
	 * @author lpshen
	 * @date 2016-8-18
	 * @return ModelAndView
	 */
	@RequestMapping("/print")
	public ModelAndView purchaseOrder(HttpSession session, String id) {
		//User user = (User) session.getAttribute("loginUser");
		ModelAndView mv = new ModelAndView("/business/professer/professer-print");
		//根据项目id查专家信息
		List<Professer> professers = this.professerService.findProfesser(id);
		Professer professer = new Professer();
		while(professers.size() < 10){
			professers.add(professer);
		}
		//根据项目id获取项目名称、编号
		String projName = this.professerService.findNameById(id);
		String projCode = this.professerService.findCodeById(id);
		
		ProfesserInfoDto professerInfo = new ProfesserInfoDto();
		professerInfo.setProfessers(professers);
		professerInfo.setProjCode(projCode);
		professerInfo.setProjName(projName);
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		professerInfo.setTime(sdf.format(new Date()));
		mv.addObject("professerInfo", professerInfo);
		return mv;
	}

}
